﻿using System;
using System . Collections . Generic;
using System . IO;
using System . Linq;
using System . Runtime . InteropServices . WindowsRuntime;
using Windows . Foundation;
using Windows . Foundation . Collections;
using Windows . UI . Xaml;
using Windows . UI . Xaml . Controls;
using Windows . UI . Xaml . Controls . Primitives;
using Windows . UI . Xaml . Data;
using Windows . UI . Xaml . Input;
using Windows . UI . Xaml . Media;
using Windows . UI . Xaml . Navigation;


namespace WenceyWang . RichMan4L . App . Pages . Controls
{
	/// <summary>
	/// 显示游戏格言
	/// </summary>
	public sealed partial class SayingPresenter : UserControl
	{

		public GameSaying Saying { get; private set; }

		public SayingPresenter ( GameSaying saying )
		{
			if ( saying == null )
			{
				throw new ArgumentNullException ( nameof ( saying ) );
			}
			Saying = saying;
			this . InitializeComponent ( );
			this . Loaded += SayingPresenter_Loaded;
		}



		private void SayingPresenter_Loaded ( object sender , RoutedEventArgs e )
		{
			VisualStateManager . GoToState ( this , nameof ( Hide ) , false );
			ContentTextBlock . Text = Saying . Context;
			if ( Saying . People != null )
			{
				PeopleTextBlock . Text = "—" + Saying . People;
			}
			else
			{
				PeopleTextBlock . Text = null;
			}
			if ( Saying . Song != null )
			{
				BookAndAuthorOrSongTextBlock . Text = "—" + Saying . Song;
			}
			else
			{
				if ( Saying . Book != null )
				{
					if ( Saying . Author != null )
					{
						BookAndAuthorOrSongTextBlock . Text = "—" + ( Saying . Context + " by " + Saying . Author );
					}
					else
					{
						BookAndAuthorOrSongTextBlock . Text = "—" + Saying . Context;
					}
				}
				else
				{
					BookAndAuthorOrSongTextBlock . Text = null;
				}
			}
		}
	}
}
